package com.Controller;

import com.Service.PoService;
import com.Utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/Po")
public class PoController {
    @Autowired
    private PoService poService;
    @PostMapping("/addPo")
    public R addPo(@RequestBody Map<String,String> Map_All) {
               String tel              =Map_All.get("tel")   ;
               String username          =Map_All.get("username")   ;
               String category1       =Map_All.get("category1")   ;
               String category2       =Map_All.get("category2")   ;
               String goodsName       =Map_All.get("goodsName")   ;
               String goodsContent       =Map_All.get("goodsContent")   ;
               String province             =Map_All.get("province")   ;
               String city             =Map_All.get("city")   ;
               String area             =Map_All.get("area")   ;
               String addressIp       =Map_All.get("addressIp")   ;
               String longitude       =Map_All.get("longitude")   ;
               String latitude       =Map_All.get("latitude")   ;
               String money             =Map_All.get("money")   ;
        return new R(poService.addPo(tel,username,category1,category2,goodsName,goodsContent,province,city,area,addressIp,longitude,latitude,money)>0);
    }
    @PostMapping("findPo")
    public R findPo(@RequestBody Map<String,String> Map_All){
        String tel =Map_All.get("tel")   ;
        String state =Map_All.get("state")   ;
        return new R(true,poService.findPo(tel,state));
    }
//    查询不同状态订单
    @PostMapping("findUserPo")
    public R findUserPo(@RequestBody Map<String,String> Map_All){
        String state =Map_All.get("state")   ;
        return new R(true,poService.findUserPo(state));
    }
//修改订单状态
@PostMapping("updataState")
public R updataState(@RequestBody Map<String,String> Map_All){
    String uuid =Map_All.get("orderUuid")   ;
    String state =Map_All.get("state")   ;
    return new R(true,poService.updataState(uuid,state));
}
}
